package com.cmzj21.springcloud.config;

import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * @author cmzj21
 * 负载均衡
 */
@Configuration
public class ApplicationContextConfig {

    /**
     * 有负载均衡作用的restTemplate
     * @return 返回一个被spring管理的有负载均衡的RestTemplate对象
     */
    @Bean
    @LoadBalanced
    public RestTemplate restTemplate()
    {
        return new RestTemplate();
    }
}
